
<?php 
//homework1
class good{
	private $name;//名称
	private $price;//价格
	private $left;//存量

	/*public function __construct($n,$p,$l){
		$this->name = $n;
		$this->price = $p;
		$this->left = $l;
	}*/


	public function int(){
		echo "我入库啦"."<br>"."<br>";
	}

	public function out(){
		echo "我卖出啦"."<br>"."<br>";
	}

	public function goodshow($name,$price,$left){
		echo"商品名:".$this->name = $name."<br>"."<br>";
		echo"价格:".$this->price = $price."<br>"."<br>";
		echo"存量:".$this->left = $left."<br>"."<br>";
	}


}

class shoes extends good{
	private $decline;//折扣率
	private $discount;//折扣价

	/*public function __construct($de,$ds){
        $this->decline = $de;
        $this->discount = $ds;
	}*/

	public function shoesshow($decline,$discount){
		echo"折扣率:".$this->decline = $decline."<br>"."<br>";
		echo"折扣价:".$this->discount = $discount."<br>"."<br>";
	}
}

$Nike = new shoes();
/*$Nike->name = "Nike";
$Nike->price = "$100";
$Nike->left = 10;
不会报错，但不显示名称，价格，存量*/
$Nike->goodshow("Nike","$100",10);
$Nike->int();
/*public function shoesshow(){
		echo"折扣率:".$this->decline."<br>";
		echo"折扣价:".$this->discount."<br>";
	}
$Nike->decline = "%10";
$Nike->discount = "$90";
报错 Fatal error: Uncaught Error: Cannot access private property shoes::$decline in E:\wampsever\www\code\11.26.php on line 54*/
$Nike->shoesshow("%10","$90");
$Nike->out();




//howework2

class Fun
{
	function fun1(){
		echo "fun1"."<br>";
	}
	function fun2(){
		echo "fun2"."<br>";
	}
	final function fun3(){
		echo "fun3"."<br>";
	}//屏蔽3的功能
	function fun4(){
		echo "fun4"."<br>";
	}
}

class MyFun extends Fun
{
	function fun1(){
		echo "newfun1"."<br>";
	}//替换1的功能
	function fun2(){
		echo "fun2"."<br>";
		echo "newfun2"."<br>";
	}//补充2的功能
	function fun4(){
		echo "fun4"."<br>";
	}//保持4的功能
}

$usemyfun = new MyFun();
$usemyfun->fun1();
$usemyfun->fun2();
$usemyfun->fun3();
$usemyfun->fun4();




//homework3
interface shape{
	public function area();//面积
	public function volume();//体积
    public function outshape();//输出具体形状的名字
}

class point implements shape {
	 private $x;//增加x
	 private $y;//增加y

     function area(){
        $area = 0;
        if($area==0){
             $area=0;}
        return $area;
     }

     function volume(){
        $volume = 0;
        if($volume==0){
              $volume=0;}
        return $volume;
     }

     function outshape(){
         echo"点"."<br>";
     }

     function pointshow(){
        echo"x:".$this->x."<br>";
	 	echo"y:".$this->y."<br>";
	 	echo"面积：".area()."<br>";
	 	echo"体积：".volume()."<br>";
	 	echo"形状：".outshape()."<br>";
     }//display
}

//homework4
class circle extends point{
	private $r;//增加r

	function area(){
        $area = 3.14*$r*$r;
        if($area==0){
             $area=0;}
        return $area;
     }

	function volume(){
        $volume = 0;
        if($volume==0){
              $volume=0;}
        return $volume;
     }

     function outshape(){
        echo"圆"."<br>";
     }

     function circleshow(){
        echo"r:".$this->r."<br>";
	 	echo"面积：".area()."<br>";
	 	echo"体积：".volume()."<br>";
	 	echo"形状：".outshape()."<br>";
     }//display
}

//howework5
class cylinder extends circle{
	private $h;//定义h

	function area(){
		$area=(2*3.14*$r*$r)+(2*3.14*$r*$h);
		return $area;
	}

	function volume(){
		$volume=(3.14*$r*$r*$h);
		return $volume;
	}

	function outshape(){
		echo"圆柱"."<br>";
	}

	function cylindershow(){
		echo"h:".$this->h."<br>";
	 	echo"面积：".area()."<br>";
	 	echo"体积：".volume()."<br>";
	 	echo"形状：".outshape()."<br>";
	}//diaplay
}

//homework6
class triangle implements shape{
	private $b;//定义底
	private $trih;//定义高

	function area(){
		$area=$b*$trih*(0.5);
		return $area;
	}

	function volume(){
        $volume = 0;
        if($volume==0){
              $volume=0;}
        return $volume;
     }

     function outshape(){
		echo"三角形"."<br>";
	}

	function triangleshow(){
		echo"b:".$this->b."<br>";
		echo"trih:".$this->trih."<br>";
	 	echo"面积：".area()."<br>";
	 	echo"体积：".volume()."<br>";
	 	echo"形状：".outshape()."<br>";
	}//diaplay
}

//homework7
class squire extends point{//继承point对象
	private $a;
	function area(){
		$area=$a*$a;
		return $area;
	}

	function volume(){
        $volume = 0;
        if($volume==0){
              $volume=0;}
        return $volume;
     }

     function outshape(){
		echo"正方形"."<br>";
	}

	function triangleshow(){
		echo"b:".$this->b."<br>";
		echo"trih:".$this->trih."<br>";
	 	echo"面积：".area()."<br>";
	 	echo"体积：".volume()."<br>";
	 	echo"形状：".outshape()."<br>";
	}//diaplay
}

?> 
